<?php
declare(strict_types=1);
//新建一个yar user页面
Class c_rpc_user extends Control
{
    private string $url = 'http://senyimiao.com/?c=rpc_server&m=server_handle';
    public function callback($retval, $callinfo)
    {
        echo '<pre>';print_r($retval);echo '<br>';
         print_r($callinfo);
    }
    //单次调用
    public function user()
    {
        $object = new Yar_Client($this->url);
        $object->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 10000);//猜应该是过期时间
        $object->SetOpt(YAR_OPT_TIMEOUT, 10000);
        $res = $object->hello('sen', 'lks');
        print_r($res);
    }
    //多次调用
    public function users()
    {
        Yar_Concurrent_Client::call($this->url, "hello", array("sen",'lks'));
        Yar_Concurrent_Client::call($this->url, "hello", array("shang",'aaa'));
        Yar_Concurrent_Client::loop();
    }
    //测试用法，尝试调用
    public function run()
    {
        $object = new Yar_Client($this->url);
        $object->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 10000);//猜应该是过期时间
        $object->SetOpt(YAR_OPT_TIMEOUT, 10000);
        $object->run(['c_index', 'redis']);
        echo 'success';
    }

}
